<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>药品审核澄清编辑（生产企业端）</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>药品审核澄清</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">招标采购管理</a></li>
            <li class="active"><a href="#">投标药品信息管理</a></li>
            <li class="active"><a href="#">药品审核澄清</a></li>
        </ol>
    </section>
    <section class="content">
       <form  id="form1" class="form-horizontal" action="${ctx}/prodDrug/complainProdDrug.html?projProdDrugId=${projProdDrugId}" method="post">
           <input type="hidden" name="prodId" value="${detail.prodId}" />
           <input type="hidden" name="opType" value="${opType}" />
           <input type="hidden" name="status" value="${detail.status}" />
           <input type="hidden" id="qualityspecId" name="qualityspecId" value="${detail.qualityspecId }">
           <input type="hidden" id="prodCompId" name="prodCompId" value="${detail.prodCompId }">
           <input type="hidden" id="prodCompCode" name="prodCompCode" value="${detail.prodCompCode }">
           <input type="hidden" id="prodCompStatus" name="prodCompStatus" value="${detail.prodCompStatus }">
           <input type="hidden" id="unit" name="unit" value="${detail.unit }">
           <input type="hidden" id="unitCode" name="unitCode" value="${detail.unitCode }"> 
           <input type="hidden" id="unitStatus" name="unitStatus" value="${detail.unitStatus }">  
           <input type="hidden" id="materialId" name="materialId" value="${detail.materialId }">
           <input type="hidden" id="materialCode" name="materialCode" value="${detail.materialCode }">
           <input type="hidden" id="materialStatus" name="materialStatus" value="${detail.materialStatus }">
           <input type="hidden" id="pharId" name="pharId" value="${detail.pharId }">
           <input type="hidden" id="pharCode" name="pharCode" value="${detail.pharCode }">
           <input type="hidden" id="pharStatus" name="pharStatus" value="${detail.pharStatus }">
           
        <div class=" box box-success">
                <div class="box-body">
                
	                <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>药品编码：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="drugCode" name="drugCode" value="${detail.drugCode}" placeholder="药品编码" type="text">
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>通用名：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="qualityspecName" name="qualityspecName" placeholder="通用名" type="text" value="${detail.qualityspecName}">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right">通用名英文：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="quality();"  class="form-control" readonly="readonly" id="qualityspecNameEng" name="qualityspecNameEng" value="${detail.qualityspecNameEng}" placeholder="通用名英文" type="text">
                        </div>
                        
                        <label class="col-sm-3 text-right">商品名：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="busName" name="busName" value="${detail.busName}" placeholder="商品名" type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>剂型：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="form" name="form" placeholder="剂型" type="text" value="${detail.formName}">
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>规格：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="spec" name="spec" placeholder="规格" type="text" value="${detail.specName}">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>转换系数：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="factor" name="factor" placeholder="转换系数，没有请填1" value="${detail.factor }" type="text">
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>包装单位：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="stdUnit();" class="form-control" readonly="readonly" id="unitName" name="unitName" placeholder="单位" value="${detail.unitName }" type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
	                    <label class="col-sm-2 text-right"><span class="required">*</span>材质：</label>
                        <div class="col-sm-3 text-left">
                             <input onclick="material();" class="form-control" readonly="readonly" id="materialName" name="materialName" placeholder="材质" value="${detail.materialName }" type="text">
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>生产企业：</label>
                        <div class="col-sm-3 text-left">
                            <input onclick="prodComp();" class="form-control" readonly="readonly" id="prodCompName" name="prodCompName" placeholder="生产企业" value="${detail.prodCompName }" type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>批准文号：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="approvalCode" name="approvalCode" placeholder="批准文号" type="text" value="${detail.approvalCode }" >
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>批准日期：</label>
                        <div class="col-sm-3 text-left">
                         <input class="form-control" type="text" id="approvalDate" name="approvalDate" value="${detail.approvalDate }"  placeholder="yyyy-MM-dd" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                        </div>
                    </div>
                   
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>基本药物属性：</label>
                        <div class="col-sm-3 text-left">
                            <select class="form-control" id="drugAttr" name="drugAttr">
                                <option value="">请选择</option>
                                <option value="1" ${ detail.drugAttr == 1 ? "selected='selected'" : "" } >国家基本药物（2012版）</option>
                                <option value="2" ${ detail.drugAttr == 2 ? "selected='selected'" : "" } >省增补基本药物</option>
                                <option value="3" ${ detail.drugAttr == 3 ? "selected='selected'" : "" } >其他</option>
                            </select>
                        </div>
                        
                        <label class="col-sm-3 text-right">基药序号：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="drugIndex" name="drugIndex" placeholder="基药序号" type="text" value="${detail.drugIndex }" />
                        </div>
                    </div>
                        
                   <div class="form-group form-group-xs">
                      <label class="col-sm-2 text-right"><span class="required">*</span>药理分类：</label>
                      <div class="col-sm-3 text-left">
                            <input onclick="dicPhar();" class="form-control" readonly="readonly" id="pharName" name="pharName" placeholder="药理分类" value="${detail.pharName}" type="text">
                       </div>
                      
                       <label class="col-sm-3 text-right"><span class="required">*</span>专利类型：</label>
                       <div class="col-sm-3 text-left">
                           <select class="form-control" id="patternType" name="patternType">
                                <option value="">请选择</option>
                                <option value="1" ${ detail.patternType == 1 ? "selected='selected'" : "" } >发明专利</option>
                                <option value="2" ${ detail.patternType == 2 ? "selected='selected'" : "" } >实用新型专利</option>
                                <option value="3" ${ detail.patternType == 3 ? "selected='selected'" : "" } >外观设计专利</option>
                                <option value="4" ${ detail.patternType == 4 ? "selected='selected'" : "" } >没有专利</option>
                                <option value="9" ${ detail.patternType == 9 ? "selected='selected'" : "" } >不详</option>
                           </select>
                       </div>
                   </div>
                        
                   <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>药品来源：</label>
                        <div class="col-sm-3 text-left">
                                <select class="form-control" id="drugSource" name="drugSource">
                                    <option value="">请选择</option>
                                    <option value="1" ${ detail.drugSource == 1 ? "selected='selected'" : "" } >国产</option>
                                    <option value="2" ${ detail.drugSource == 2 ? "selected='selected'" : "" } >进口</option>
                                    <option value="9" ${ detail.drugSource == 9 ? "selected='selected'" : "" } >不详</option>
                                </select>
                            
                        </div>
                        
                        <label class="col-sm-3 text-right"><span class="required">*</span>是否低价药：</label>
                        <div class="col-sm-3 text-left">
                            <select class="form-control" id="isLowprice" name="isLowprice">
                                <option value="">请选择</option>
                                <option value="1" ${ detail.isLowprice == 1 ? "selected='selected'" : "" } >是</option>
                                <option value="0" ${ detail.isLowprice == 0 ? "selected='selected'" : "" } >否</option>
                                <option value="9" ${ detail.isLowprice == 9 ? "selected='selected'" : "" } >未知</option>
                            </select>
                        </div>
                   </div>
                        
                   <div class="form-group  form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>是否农合：</label>
                        <div class="col-sm-3 text-left">
                             <select class="form-control" id="isAgriculture" name="isAgriculture">
                                 <option value="">请选择</option>
                                 <option value="1" ${ detail.isAgriculture == 1 ? "selected='selected'" : "" } >是</option>
                                 <option value="0" ${ detail.isAgriculture == 0 ? "selected='selected'" : "" } >否</option>
                                 <option value="9" ${ detail.isAgriculture == 9 ? "selected='selected'" : "" } >未知</option>
                             </select>
                         </div>
                         
                         <label class="col-sm-3 text-right"><span class="required">*</span>是否医保：</label>
                         <div class="col-sm-3 text-left">
                              <select class="form-control" id="isHealthcare" name="isHealthcare">
                                   <option value="">请选择</option>
                                   <option value="1" ${ detail.isHealthcare == 1 ? "selected='selected'" : "" } >是</option>
                                   <option value="0" ${ detail.isHealthcare == 0 ? "selected='selected'" : "" } >否</option>
                                   <option value="9" ${ detail.isHealthcare == 9 ? "selected='selected'" : "" } >未知</option>
                              </select>
                         </div>
                    </div>
                        
                    <div class="form-group form-group-xs">
                         <label class="col-sm-2 text-right"><span class="required">*</span>药品本位码：</label>
                         <div class="col-sm-3 text-left">
                               <input class="form-control" id="drugStdCode" name="drugStdCode" placeholder="药品本位码" type="text" value="${detail.drugStdCode }">
                         </div>
                    </div>
                       
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right">药品本位码备注：</label>
                          <div class="col-sm-9 text-left">
                               <textarea class="form-control" id="drugStdcdRemark" name="drugStdcdRemark" rows="3" placeholder="药品本位码备注" >${detail.drugStdcdRemark }</textarea> 
                          </div>
                     </div>
                       
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right">说明：</label>
                          <div class="col-sm-9 text-left">
                               <textarea class="form-control" id="remark" name="remark" rows="3" placeholder="说明 ...">${detail.remark }</textarea>
                          </div>
                     </div>
                     
                     <div class="box-footer text-center">
                        <button type="button" onclick="save();" class="btn btn-success btn-sm">保&nbsp;存</button>
                        <a href="javascript:history.go(-1)" class="btn btn-danger btn-sm">返&nbsp;回</a>
                     </div>
                </div>
               </div>
          </form>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %> 
    <script type="text/javascript">
    
	     //保存
	     function save() {
	    	if (!validate()) {
                return;
            }  
            $.HN.message.confirm('确定要保存吗？', '', '').on(function (e) {
               if (e) {
			            $("#form1").ajaxSubmit({
			                dataType : "json",
			                timeout: 10000,
			                success : function(result, statusText) {
			                    if (result.success) {
			                        $.alert("操作成功！", "success", function() {
			                            document.location = "${ctx }/stdProdDrugInfo/toStdProdDrugInfoList.html";
			                        });
			                    } else {
			                        $.alert(result.msg || "操作失败", "error");
			                    }
			                }
			            });
                   }
              });
            
        }
	    
	  
	  
	  
	//通用名、剂型、规格弹窗
	  function quality(){
	        var url = "${ctx}/stdProdDrugInfo/toSelectQualityspec.html";
	      $.HN.dialog.open({
	          "id": "quality",
	          "title": "品规库", 
	          "url": url, 
	          "data": {}, 
	          "width": 800, 
	          "height": 510, 
	          "closefunc":function(params) {
	              if (params) {
	            	  $("#qualityspecId").val(params.qualityspecId);
	                  $("#spec").val(params.specName);
	                  $("#form").val(params.formName);
	                  $("#qualityspecName").val(params.qualityspecName);
	                  $("#qualityspecNameEng").val(params.qualityspecNameEng);
	              }
	          }
	      });   
	  }
	  
	//生产企业弹窗
	  function prodComp() {
	       var url = "${ctx}/stdProdDrugInfo/toSelectProdComp.html";
	      $.HN.dialog.open({
	          "id": "prodComp",
	          "title": "企业信息库", 
	          "url": url, 
	          "data": {}, 
	          "width": 800, 
	          "height": 540, 
	          "closefunc":function(params) {
	              if (params) {
	                  $("#prodCompName").val(params.prodCompName);
	                  $("#prodCompId").val(params.prodCompId);
	                  $("#prodCompCode").val(params.prodCompCode);
	                  $("#prodCompStatus").val(params.prodCompStatus);
	              }
	          }
	      }); 
	  }
	
	   //药理分类 弹窗
      function dicPhar() {
           var url = "${ctx}/stdProdDrugInfo/toSelectPhar.html";
          $.HN.dialog.open({
              "id": "dicPhar",
              "title": "药理分类库", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#pharName").val(params.pharName);
                      $("#pharId").val(params.pharId);
                      $("#pharCode").val(params.pharCode);
                      $("#pharStatus").val(params.pharStatus);
                  }
              }
          }); 
      }
  
    //材质  弹窗
      function material() {
           var url = "${ctx}/stdProdDrugInfo/toSelectMaterial.html";
          $.HN.dialog.open({
              "id": "material",
              "title": "材质库", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#materialName").val(params.materialName);
                      $("#materialId").val(params.materialId);
                      $("#materialCode").val(params.materialCode);
                      $("#materialStatus").val(params.materialStatus);
                  }
              }
          }); 
      }
    
      //单位  弹窗
      function stdUnit() {
           var url = "${ctx}/stdProdDrugInfo/toSelectUnit.html";
          $.HN.dialog.open({
              "id": "stdUnit",
              "title": "包装单位库", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#unitName").val(params.unitName);
                      $("#unit").val(params.unitId);
                      $("#unitCode").val(params.unitCode);
                      $("#unitStatus").val(params.unitStatus);
                  }
              }
          }); 
      }
      
      
      
    //效验
      function validate() {
          
          var drugCode = $.trim($("#drugCode").val());
          if (drugCode == null || drugCode == "") {
              $.alert("药品编码不能为空！请输入", "warn");
              return false;
          } else if (!/^[a-zA-Z0-9_]+$/.test(drugCode)) {
              $.alert("药品编码只能由字母数字下划线组成！", "warn");
              return false;
          }else if (drugCode.length > 128) {
              $.alert("药品编码字数超过限制！请重新输入", "warn");
              return false;
          }
          
          var qualityspecName = $.trim($("#qualityspecName").val());
          if (qualityspecName == null || qualityspecName == "") {
              $.alert("通用名不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var form = $.trim($("#form").val());
          if (form == null || form == "") {
              $.alert("剂型不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var busName = $.trim($("#busName").val());
          if (busName != null && busName != "" && busName.length >256 ) {
              $.alert("商品名字数超过限制", "warn");
              return false;
          }
          
          var spec = $.trim($("#spec").val());
          if (spec == null || spec == "") {
              $.alert("规格不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var factor = $.trim($("#factor").val());
          if (factor == null || factor == "") {
              $.alert("转换系数不能为空！请输入", "warn");
              return false;
          }else if (!/^[0-9]+$/.test(factor)) {
              $.alert("转换系数只能由数字组成！", "warn");
              return false;
          }else if (factor.length >11 ) {
              $.alert("转换系数字数超过限制", "warn");
              return false;
          }
          
          var unitName = $.trim($("#unitName").val());
          if (unitName == null || unitName == "") {
              $.alert("单位不能为空！请输入", "warn");
              return false;
          }
          
          var materialName = $.trim($("#materialName").val());
          if (materialName == null || materialName == "") {
              $.alert("材质不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var prodCompName = $.trim($("#prodCompName").val());
          if (prodCompName == null || prodCompName == "") {
              $.alert("生产企业不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var approvalCode = $.trim($("#approvalCode").val());
          if (approvalCode == null || approvalCode == "") {
              $.alert("批准文号不能为空！请输入", "warn");
              return false;
          }else if (approvalCode.length >100 ) {
              $.alert("批准文号字数超过限制", "warn");
              return false;
          }
          
          var approvalDate = $.trim($("#approvalDate").val());
          if (approvalDate == null || approvalDate == "") {
              $.alert("批准日期不能为空！请点击选择", "warn");
              return false;
          }
          
          var drugAttr = $.trim($("#drugAttr").val());
          if (drugAttr == null || drugAttr == "") {
              $.alert("基本药物属性不能为空！请点击选择", "warn");
              return false;
          }
          
         var drugIndex = $.trim($("#drugIndex").val());
          if (drugIndex != null && drugIndex != "" && !/^[0-9]+$/.test(drugIndex)) {
              $.alert("基药序号只能由数字组成！", "warn");
              return false;
          }else if (drugIndex.length >100 ) {
              $.alert("基药序号字数超过限制", "warn");
              return false;
          } 
          
          var pharName = $.trim($("#pharName").val());
          if (pharName == null || pharName == "") {
              $.alert("药理分类不能为空！请点击弹窗选择", "warn");
              return false;
          }
          
          var patternType = $.trim($("#patternType").val());
          if (patternType == null || patternType == "") {
              $.alert("专利类型不能为空！请点击选择", "warn");
              return false;
          }
          
          var drugSource = $.trim($("#drugSource").val());
          if (drugSource == null || drugSource == "") {
              $.alert("药品来源不能为空！请点击选择", "warn");
              return false;
          }
          
          var isLowprice = $.trim($("#isLowprice").val());
          if (isLowprice == null || isLowprice == "") {
              $.alert("是否低价药不能为空！请点击选择", "warn");
              return false;
          }
          
          var isAgriculture = $.trim($("#isAgriculture").val());
          if (isAgriculture == null || isAgriculture == "") {
              $.alert("是否农合不能为空！请点击选择", "warn");
              return false;
          }
          
          var isHealthcare = $.trim($("#isHealthcare").val());
          if (isHealthcare == null || isHealthcare == "") {
              $.alert("是否医保不能为空！请点击选择", "warn");
              return false;
          }
          
          var drugStdCode = $.trim($("#drugStdCode").val());
          if (drugStdCode == null || drugStdCode == "") {
              $.alert("药品本位码不能为空！请输入", "warn");
              return false;
          }else if (drugStdCode.length >100 ) {
              $.alert("药品本位码字数超过限制", "warn");
              return false;
          } 

          return true;
      }
	   
    </script>
</body>
</html>